<!DOCTYPE html><html><head><title>README</title><link href="http://www.jboss.org/jdf/stylesheets/documentation.css" rel="stylesheet"></link><link href="http://www.jboss.org/jdf/stylesheets/pygments.css" rel="stylesheet"></link></head><body>
<h1><a id="helloworldws-hello-world-jaxws-web-service" class="anchor" href="#helloworldws-hello-world-jaxws-web-service"><span class="anchor-icon"></span></a>helloworld-ws: Hello World JAX-WS Web Service</h1>

<p>Author: Lee Newson<br/>
Level: Beginner<br/>
Technologies: JAX-WS<br/>
Summary: Deployment of a basic JAX-WS Web service bundled in a WAR archive<br/>
Target Product: EAP<br/>
Product Versions: EAP 6.1, EAP 6.2<br/>
Source: <a href="https://github.com/jboss-developer/jboss-eap-quickstarts/">https://github.com/jboss-developer/jboss-eap-quickstarts/</a>  </p>

<h2><a id="what-is-it" class="anchor" href="#what-is-it"><span class="anchor-icon"></span></a>What is it?</h2>

<p>This example demonstrates the use of <em>JAX-WS</em> in Red Hat JBoss Enterprise Application Platform as a simple Hello World application.</p>

<h2><a id="system-requirements" class="anchor" href="#system-requirements"><span class="anchor-icon"></span></a>System requirements</h2>

<p>The application this project produces is designed to be run on Red Hat JBoss Enterprise Application Platform 6.1 or later.</p>

<p>All you need to build this project is Java 6.0 (Java SDK 1.6) or later, Maven 3.0 or later.</p>

<h2><a id="configure-maven" class="anchor" href="#configure-maven"><span class="anchor-icon"></span></a>Configure Maven</h2>

<p>If you have not yet done so, you must <a href="../README.html#configure-maven">Configure Maven</a> before testing the quickstarts.</p>

<h2><a id="start-the-jboss-server" class="anchor" href="#start-the-jboss-server"><span class="anchor-icon"></span></a>Start the JBoss Server</h2>

<ol>
<li>Open a command line and navigate to the root of the JBoss server directory.</li>
<li><p>The following shows the command line to start the server:</p>
<div class="highlight"><pre><span class="n">For</span> <span class="n">Linux</span><span class="o">:</span>   <span class="n">JBOSS_HOME</span><span class="o">/</span><span class="n">bin</span><span class="o">/</span><span class="n">standalone</span><span class="p">.</span><span class="n">sh</span>
<span class="n">For</span> <span class="n">Windows</span><span class="o">:</span> <span class="n">JBOSS_HOME</span><span class="err">\</span><span class="n">bin</span><span class="err">\</span><span class="n">standalone</span><span class="p">.</span><span class="n">bat</span>
</pre></div></li>
</ol>

<h2><a id="build-and-deploy-the-quickstart" class="anchor" href="#build-and-deploy-the-quickstart"><span class="anchor-icon"></span></a>Build and Deploy the Quickstart</h2>

<p><em>NOTE: The following build command assumes you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See <a href="../README.html#build-and-deploy-the-quickstarts">Build and Deploy the Quickstarts</a> for complete instructions and additional options.</em></p>

<ol>
<li>Make sure you have started the JBoss Server as described above.</li>
<li>Open a command line and navigate to the root directory of this quickstart.</li>
<li><p>Type this command to build and deploy the archive:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">install</span> <span class="n">jboss</span><span class="o">-</span><span class="n">as</span><span class="o">:</span><span class="n">deploy</span>
</pre></div></li>
<li><p>This will deploy <code>target/jboss-helloworld-ws.war</code> to the running instance of the server.</p></li>
</ol>

<h2><a id="access-the-application-" class="anchor" href="#access-the-application-"><span class="anchor-icon"></span></a>Access the application </h2>

<p>You can check that the Web Service is running and deployed correctly by accessing the following URL: <a href="http://localhost:8080/jboss-helloworld-ws?wsdl">http://localhost:8080/jboss-helloworld-ws?wsdl</a>. This URL will display the deployed WSDL endpoint for the Web Service.</p>

<h2><a id="undeploy-the-archive" class="anchor" href="#undeploy-the-archive"><span class="anchor-icon"></span></a>Undeploy the Archive</h2>

<ol>
<li>Make sure you have started the JBoss Server as described above.</li>
<li>Open a command line and navigate to the root directory of this quickstart.</li>
<li><p>When you are finished testing, type this command to undeploy the archive:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">jboss</span><span class="o">-</span><span class="n">as</span><span class="o">:</span><span class="n">undeploy</span>
</pre></div></li>
</ol>

<h2><a id="run-the-client-tests-using-arquillian" class="anchor" href="#run-the-client-tests-using-arquillian"><span class="anchor-icon"></span></a>Run the Client Tests using Arquillian</h2>

<p>This quickstart provides Arquillian tests. By default, these tests are configured to be skipped as Arquillian tests require the use of a container. </p>

<p><em>NOTE: The following commands assume you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See <a href="../README.html#run-the-arquillian-tests">Run the Arquillian Tests</a> for complete instructions and additional options.</em></p>

<ol>
<li>Make sure you have started the JBoss Server as described above.</li>
<li>Open a command line and navigate to the root directory of this quickstart.</li>
<li><p>Type the following command to run the test goal with the following profile activated:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">test</span> <span class="o">-</span><span class="n">Parq</span><span class="o">-</span><span class="n">jbossas</span><span class="o">-</span><span class="n">remote</span>
</pre></div></li>
</ol>

<h2><a id="investigate-the-console-output" class="anchor" href="#investigate-the-console-output"><span class="anchor-icon"></span></a>Investigate the Console Output</h2>

<p>The following expected output should appear. The output shows what was said to the Web Service by the client and the responses it received.</p>
<div class="highlight"><pre><span class="n">WSDL</span> <span class="n">Deployment</span> <span class="n">URL</span><span class="o">:</span> <span class="n">http</span><span class="o">:</span><span class="c1">//localhost:8080/jboss-helloworld-ws/HelloWorldService?wsdl</span>
<span class="p">[</span><span class="n">Client</span><span class="p">]</span> <span class="n">Requesting</span> <span class="n">the</span> <span class="n">WebService</span> <span class="n">to</span> <span class="n">say</span> <span class="n">Hello</span><span class="p">.</span>
<span class="p">[</span><span class="n">WebService</span><span class="p">]</span> <span class="n">Hello</span> <span class="n">World</span><span class="o">!</span>
<span class="p">[</span><span class="n">Client</span><span class="p">]</span> <span class="n">Requesting</span> <span class="n">the</span> <span class="n">WebService</span> <span class="n">to</span> <span class="n">say</span> <span class="n">Hello</span> <span class="n">to</span> <span class="n">John</span><span class="p">.</span>
<span class="p">[</span><span class="n">WebService</span><span class="p">]</span> <span class="n">Hello</span> <span class="n">John</span><span class="o">!</span>
<span class="p">[</span><span class="n">Client</span><span class="p">]</span> <span class="n">Requesting</span> <span class="n">the</span> <span class="n">WebService</span> <span class="n">to</span> <span class="n">say</span> <span class="n">Hello</span> <span class="n">to</span> <span class="n">John</span><span class="p">,</span> <span class="n">Mary</span> <span class="n">and</span> <span class="n">Mark</span><span class="p">.</span>
<span class="p">[</span><span class="n">WebService</span><span class="p">]</span> <span class="n">Hello</span> <span class="n">John</span><span class="p">,</span> <span class="n">Mary</span> <span class="o">&amp;</span> <span class="n">Mark</span><span class="o">!</span>
<span class="n">Tests</span> <span class="n">run</span><span class="o">:</span> <span class="mi">3</span><span class="p">,</span> <span class="n">Failures</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="n">Errors</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="n">Skipped</span><span class="o">:</span> <span class="mi">0</span><span class="p">,</span> <span class="n">Time</span> <span class="n">elapsed</span><span class="o">:</span> <span class="mf">1.988</span> <span class="n">sec</span>
</pre></div>
<h2><a id="run-the-quickstart-in-jboss-developer-studio-or-eclipse" class="anchor" href="#run-the-quickstart-in-jboss-developer-studio-or-eclipse"><span class="anchor-icon"></span></a>Run the Quickstart in JBoss Developer Studio or Eclipse</h2>

<p>You can also start the server and deploy the quickstarts from Eclipse using JBoss tools. For more information, see <a href="../README.html#use-jboss-developer-studio-or-eclipse-to-run-the-quickstarts">Use JBoss Developer Studio or Eclipse to Run the Quickstarts</a> </p>

<h2><a id="debug-the-application" class="anchor" href="#debug-the-application"><span class="anchor-icon"></span></a>Debug the Application</h2>

<p>If you want to debug the source code or look at the Javadocs of any library in the project, run either of the following commands to pull them into your local repository. The IDE should then detect them.</p>
<div class="highlight"><pre>    <span class="n">mvn</span> <span class="n">dependency</span><span class="o">:</span><span class="n">sources</span>
    <span class="n">mvn</span> <span class="n">dependency</span><span class="o">:</span><span class="n">resolve</span> <span class="o">-</span><span class="n">Dclassifier</span><span class="o">=</span><span class="n">javadoc</span>
</pre></div>
<h2><a id="build-and-deploy-the-quickstart-to-openshift" class="anchor" href="#build-and-deploy-the-quickstart-to-openshift"><span class="anchor-icon"></span></a>Build and Deploy the Quickstart - to OpenShift</h2>

<h3><a id="create-an-openshift-express-account-and-domain" class="anchor" href="#create-an-openshift-express-account-and-domain"><span class="anchor-icon"></span></a>Create an OpenShift Express Account and Domain</h3>

<p>If you do not yet have an OpenShift account and domain, <a href="https://openshift.redhat.com/app/login">Sign in to OpenShift</a> to create the account and domain. <a href="https://openshift.redhat.com/app/getting_started">Get Started with OpenShift</a> will show you how to install the OpenShift Express command line interface.</p>

<h3><a id="create-the-openshift-application" class="anchor" href="#create-the-openshift-application"><span class="anchor-icon"></span></a>Create the OpenShift Application</h3>

<p>Note that we use <code>USER_DOMAIN_NAME</code> for these examples. You need to substitute it with your own OpenShift account user name.</p>

<p>Open a shell command prompt and change to a directory of your choice. Enter the following command to create a JBoss EAP 6 application:</p>
<div class="highlight"><pre><span class="n">rhc</span> <span class="n">app</span> <span class="n">create</span> <span class="o">-</span><span class="n">a</span> <span class="n">helloworldws</span> <span class="o">-</span><span class="n">t</span> <span class="n">jbosseap</span><span class="o">-</span><span class="mi">6</span>
</pre></div>
<p><em>NOTE</em>: The domain name for this application will be <code>helloworldws-YOUR_DOMAIN_NAME.rhcloud.com</code>. Be sure to replace <code>YOUR_DOMAIN_NAME</code> with your own OpenShift account user name.</p>

<p>This command creates an OpenShift application called <code>helloworldws</code> and will run the application inside the <code>jbosseap-6</code> container. You should see some output similar to the following:</p>
<div class="highlight"><pre><span class="gh">Application Options</span>
<span class="gh">-------------------</span>
  Namespace:  YOUR_DOMAIN_NAME
  Cartridges: jbosseap-6 (addtl. costs may apply)
  Gear Size:  default
  Scaling:    no

Creating application &#39;helloworldws&#39; ... done

Waiting for your DNS name to be available ... done

Cloning into &#39;helloworldws&#39;...
Warning: Permanently added the RSA host key for IP address &#39;54.237.58.0&#39; to the list of known hosts.

Your application &#39;helloworldws&#39; is now available.

  URL:        http://helloworldws-YOUR_DOMAIN_NAME.rhcloud.com/
  SSH to:     52864af85973ca430200006f@helloworldws-YOUR_DOMAIN_NAME.rhcloud.com
  Git remote: ssh://52864af85973ca430200006f@helloworldws-YOUR_DOMAIN_NAME.rhcloud.com/~/git/helloworldws.git/
  Cloned to:  CURRENT_DIRECTORY/helloworldws

Run &#39;rhc show-app helloworldws&#39; for more details about your app.
</pre></div>
<p>The create command creates a git repository in the current directory with the same name as the application, in this case, <code>helloworldws</code>. Notice that the output also reports the URL at which the application can be accessed. Make sure it is available by typing the published url <a href="http://helloworldws-YOUR_DOMAIN_NAME.rhcloud.com/">http://helloworldws-YOUR_DOMAIN_NAME.rhcloud.com/</a> into a browser or use command line tools such as curl or wget. Be sure to replace <code>YOUR_DOMAIN_NAME</code> with your OpenShift account domain name.</p>

<h3><a id="migrate-the-quickstart-source" class="anchor" href="#migrate-the-quickstart-source"><span class="anchor-icon"></span></a>Migrate the Quickstart Source</h3>

<p>Now that you have confirmed it is working you can now migrate the quickstart source and POM file. You no longer need the default application, so change directory into the new git repository and tell git to remove the source and pom files:</p>
<div class="highlight"><pre><span class="n">cd</span> <span class="n">helloworldws</span>
<span class="n">git</span> <span class="n">rm</span> <span class="o">-</span><span class="n">r</span> <span class="n">src</span> <span class="n">pom</span><span class="p">.</span><span class="n">xml</span>
</pre></div>
<p>Copy the source and POM file for the <code>helloworld-ws</code> quickstart into this new git repository:</p>
<div class="highlight"><pre><span class="n">cp</span> <span class="o">-</span><span class="n">r</span> <span class="n">QUICKSTART_HOME</span><span class="o">/</span><span class="n">helloworld</span><span class="o">-</span><span class="n">ws</span><span class="o">/</span><span class="n">src</span> <span class="p">.</span>
<span class="n">cp</span> <span class="n">QUICKSTART_HOME</span><span class="o">/</span><span class="n">helloworld</span><span class="o">-</span><span class="n">ws</span><span class="o">/</span><span class="n">pom</span><span class="p">.</span><span class="n">xml</span> <span class="p">.</span>
</pre></div>
<h3><a id="configure-the-openshift-server" class="anchor" href="#configure-the-openshift-server"><span class="anchor-icon"></span></a>Configure the OpenShift Server</h3>

<p>Verify that Openshift has Web services configured by default. To do this: </p>

<ol>
<li>Open the hidden <code>.openshift/config/standalone.xml</code> file in an editor. </li>
<li><p>If the <code>webservices</code> subsystem is not configured as below under the <code>&lt;profile&gt;</code> element, copy the following and replace the <code>webservices</code> subsystem to enable and configure Web Services:</p>
<div class="highlight"><pre><span class="nt">&lt;subsystem</span> <span class="na">xmlns=</span><span class="s">&quot;urn:jboss:domain:webservices:1.1&quot;</span><span class="nt">&gt;</span>
    <span class="nt">&lt;modify</span><span class="err">-wsdl-address</span><span class="nt">&gt;</span>true<span class="nt">&lt;/modify-wsdl-address&gt;</span>
    <span class="nt">&lt;wsdl</span><span class="err">-host</span><span class="nt">&gt;</span><span class="cp">${</span><span class="n">env</span><span class="o">.</span><span class="n">OPENSHIFT_APP_DNS</span><span class="cp">}</span><span class="nt">&lt;/wsdl-host&gt;</span>
    <span class="nt">&lt;wsdl</span><span class="err">-port</span><span class="nt">&gt;</span>80<span class="nt">&lt;/wsdl-port&gt;</span>
    <span class="nt">&lt;endpoint</span><span class="err">-config</span> <span class="na">name=</span><span class="s">&quot;Standard-Endpoint-Config&quot;/</span><span class="nt">&gt;</span>
    <span class="nt">&lt;endpoint</span><span class="err">-config</span> <span class="na">name=</span><span class="s">&quot;Recording-Endpoint-Config&quot;</span><span class="nt">&gt;</span>
        <span class="nt">&lt;pre</span><span class="err">-handler-chain</span> <span class="na">name=</span><span class="s">&quot;recording-handlers&quot;</span> <span class="na">protocol-bindings=</span><span class="s">&quot;##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM&quot;</span><span class="nt">&gt;</span>
            <span class="nt">&lt;handler</span> <span class="na">name=</span><span class="s">&quot;RecordingHandler&quot;</span> <span class="na">class=</span><span class="s">&quot;org.jboss.ws.common.invocation.RecordingServerHandler&quot;/</span><span class="nt">&gt;</span>
        <span class="nt">&lt;/pre-handler-chain&gt;</span>
    <span class="nt">&lt;/endpoint-config&gt;</span>
<span class="nt">&lt;/subsystem&gt;</span>
</pre></div></li>
</ol>

<h3><a id="deploy-the-openshift-application" class="anchor" href="#deploy-the-openshift-application"><span class="anchor-icon"></span></a>Deploy the OpenShift Application</h3>

<p>You can now deploy the changes to your OpenShift application using git as follows:</p>
<div class="highlight"><pre><span class="n">git</span> <span class="n">add</span> <span class="n">src</span> <span class="n">pom</span><span class="p">.</span><span class="n">xml</span>
<span class="n">git</span> <span class="n">commit</span> <span class="o">-</span><span class="n">m</span> <span class="s">&quot;helloworld-ws quickstart on OpenShift&quot;</span>
<span class="n">git</span> <span class="n">push</span>
</pre></div>
<p>The final push command triggers the OpenShift infrastructure to build and deploy the changes. </p>

<p>Note that the <code>openshift</code> profile in <code>pom.xml</code> file is activated by OpenShift and causes the WAR built by openshift to be copied to the <code>deployments/</code> directory and deployed to the &ldquo;jboss-helloworld-ws&rdquo; context path.</p>

<h3><a id="access-the-openshift-application" class="anchor" href="#access-the-openshift-application"><span class="anchor-icon"></span></a>Access the OpenShift Application</h3>

<p>Now you will start to tail the log files of the server. To do this run the following command, remembering to replace the application name and login id.</p>
<div class="highlight"><pre><span class="n">rhc</span> <span class="n">tail</span> <span class="n">helloworldws</span>
</pre></div>
<p>Once the application is deployed, you can test the application by accessing the following URL either via a browser or using tools such as curl or wget. Be sure to replace the <code>YOUR_DOMAIN_NAME</code> in the URL with your OpenShift account domain name.</p>
<div class="highlight"><pre><span class="nl">http:</span><span class="c1">//helloworldws-YOUR_DOMAIN_NAME.rhcloud.com/jboss-helloworld-ws/HelloWorldService?wsdl</span>
</pre></div>
<p>If the application has run successfully you should see the WSDL output in the browser.</p>

<p>You can use the OpenShift command line tools or the OpenShift web console to discover and control the application.</p>

<h3><a id="run-the-remote-client-tests-against-openshift" class="anchor" href="#run-the-remote-client-tests-against-openshift"><span class="anchor-icon"></span></a>Run the Remote Client Tests against Openshift</h3>

<p>This quickstart provides tests that can be run remotely. By default, these tests are configured to be skipped as the tests require the application to be running remotely. </p>

<p><em>NOTE: The following commands assume you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line..</em></p>

<ol>
<li>Make sure you have deployed the Application to Openshift as described above.</li>
<li><p>Type the following command to run the test goal with the following profile activated and the URL of the deployed Application. Be sure to replaces <code>YOUR_DOMAIN_NAME</code> in the URL with your OpenShift account domain name:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">test</span> <span class="o">-</span><span class="n">Pjbossas</span><span class="o">-</span><span class="n">remote</span> <span class="o">-</span><span class="n">Dremote</span><span class="p">.</span><span class="n">server</span><span class="p">.</span><span class="n">url</span><span class="o">=</span><span class="n">http</span><span class="o">:</span><span class="c1">//helloworldws-YOUR_DOMAIN_NAME.rhcloud.com/</span>
</pre></div></li>
</ol>

<h3><a id="delete-the-openshift-application" class="anchor" href="#delete-the-openshift-application"><span class="anchor-icon"></span></a>Delete the OpenShift Application</h3>

<p>When you are finished with the application you can delete it from OpenShift as follows:</p>
<div class="highlight"><pre><span class="n">rhc</span> <span class="n">app</span><span class="o">-</span><span class="n">delete</span> <span class="o">-</span><span class="n">a</span> <span class="n">helloworldws</span>
</pre></div>
<p><em>Note</em>: There is a limit to the number of applications you can deploy concurrently to OpenShift. If the <code>rhc app create</code> command returns an error indicating you have reached that limit, you must delete an existing application before you continue. </p>

<ul>
<li>To view the list of your OpenShift applications, type: <code>rhc domain show</code></li>
<li>To delete an application from OpenShift, type the following, substituting the application name you want to delete: <code>rhc app-delete -a APPLICATION_NAME_TO_DELETE</code></li>
</ul>
</body></html>
